package com.tbs.parkingsaleapp.Http.Listenner;

import abstergo.tbs.betterasyc.AsycBase.IAsycBackgroundAction;
import abstergo.tbs.betterasyc.AsycBase.IAsycResultAction;
import android.widget.ListView;
import com.alibaba.fastjson.JSON;
import com.tbs.parkingsaleapp.Http.HttpHelper;
import com.tbs.parkingsaleapp.Http.JsonData.OrderInfo;
import com.tbs.parkingsaleapp.R;
import com.tbs.parkingsaleapp.SystemManager.NetWorkSetting;
import com.tbs.parkingsaleapp.UI.Adapters.OrderAdapter;
import com.tbs.parkingsaleapp.UI.OrderPage.OrderPageFragment;

public class MyOrderHttper implements IAsycBackgroundAction<String, OrderInfo[]>, IAsycResultAction<OrderInfo[]> {

    ListView ls;
    public MyOrderHttper(ListView lsview)
    {
        this.ls=lsview;
    }
    @Override
    public OrderInfo[] BackGroundAction(String... params) throws Exception {
       String r= HttpHelper.Get(NetWorkSetting.FindAllOrderUrl(params[0]));
        return JSON.parseObject(r,OrderInfo[].class);
    }

    @Override
    public void ResultFunction(OrderInfo[] result) {
        ls.setDivider(ls.getContext().getDrawable(R.drawable.blank));
        ls.setDividerHeight(28);
        ls.setAdapter(new OrderAdapter(ls.getContext(),result,ls));
        OrderPageFragment.SpinnerReady();
    }
}
